/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package FMMLogic;

import be.ac.ulg.montefiore.run.jahmm.ViterbiCalculator;
import Domain.State;
import Domain.Output;
import be.ac.ulg.montefiore.run.jahmm.Hmm;
import be.ac.ulg.montefiore.run.jahmm.ObservationDiscrete;
import Adapter.DomainAdapter;
import be.ac.ulg.montefiore.run.jahmm.ForwardBackwardCalculator;
import java.util.List;
/**
 *
 * @author Allen
 * @author Ryan
 */
public class LFMMPredictor {
    /*Viterbi predictor*/
    ViterbiCalculator vtb;
    DomainAdapter adptor;
    ForwardBackwardCalculator fb;

    public LFMMPredictor () {
        vtb = null;
        fb =  null;
        adptor = new DomainAdapter();
    }
    public boolean initViterbi( Output[] seq,
                                Hmm<ObservationDiscrete<Output>> hmm){

        List<ObservationDiscrete<Output>> oseq = adptor.toObservation(seq);
        vtb = new ViterbiCalculator(oseq, hmm);

        return true;
    }
    public boolean initFb( Output[] seq,
                                Hmm<ObservationDiscrete<Output>> hmm){

        List<ObservationDiscrete<Output>> oseq = adptor.toObservation(seq);
        fb = new ForwardBackwardCalculator(oseq, hmm);

        return true;
    }
    public State [] stateSequence() {
        int [] i_result = vtb.stateSequence();
        State []  s_result = adptor.itoState(i_result);

        return s_result;
    }
    public double Probability() {
        double result = fb.probability();
        return result;
    }
}
